﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace OnlineSoccerManager.Converter
{
    public class PositiveNegativeForegroundConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Color color = Colors.Black;
            if (value is decimal? && ((decimal?)value).HasValue)
                color = (decimal)value < 0 ? Colors.Red : ((decimal)value > 0 ? Colors.Green : Colors.Black);
            if (value is int? && ((int?)value).HasValue)
                color = (int)value < 0 ? Colors.Red : ((int)value > 0 ? Colors.Green : Colors.Black);
            if (value is long? && ((long?)value).HasValue)
                color = (long)value < 0 ? Colors.Red : ((long)value > 0 ? Colors.Green : Colors.Black);
            if (value is decimal)
                color = (decimal)value < 0 ? Colors.Red : ((decimal)value > 0 ? Colors.Green : Colors.Black);
            if (value is int)
                color = (int)value < 0 ? Colors.Red : ((int)value > 0 ? Colors.Green : Colors.Black);
            if (value is long)
                color = (long)value < 0 ? Colors.Red : ((long)value > 0 ? Colors.Green : Colors.Black);

            return color;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
